/**
 * 
 */
package fr.lelouet.ga.examples.multOf11;

import fr.lelouet.ga.Combinator;

import java.util.HashSet;
import java.util.Set;

/**
 * @author guigolum
 */
public class CombinatorAdd implements Combinator<Integer> {

    @Override
    public Set<Integer> combination(final Set<Integer> set) {
        final Set<Integer> retour = new HashSet<Integer>();
        int last = 0;
        int yetAdded = 0;
        for (final Integer i : set) {
            last += i;
            yetAdded++;
            if (yetAdded == 2) {
                retour.add(last);
                last = 0;
                yetAdded = 0;
            }
        }
        return retour;
    }

}
